#!/usr/bin/env python
# -*- coding: utf-8 -*-
#

'''
Pedro Santos nº12065
Rui Pereira nº12061
'''

'''
->>compilar o codigo em C em uma biblioteca partilhada

rpereira@Debian:~$ gcc -c -fPIC aleatorio_C.c
rpereira@Debian:~$ gcc -shared aleatorio_C.o -o aleatorio_C.so

->>chamar a funcao em c no python

rpereira@Debian:~$python aleatorio_C.py
rpereira@Debian:~$cat aleatorio_C.py

'''
import time
import os
import random
import sys
import subprocess


os.system('clear')
begin_time = time.clock()


from ctypes import *
gerador=CDLL('/home/Admin1/MESI/aleatorio_C.so')

aleatorio_C.preencher_tabela((byref(T))
aleatorio_C.switchTab(l, (byref(T))
aleatorio_C.Acha_z(p, (byref(Z), byref(T))
aleatorio_C.repete_k(k, (byref(Z), byref(T))




l=c_int()
p=c_int()
k=c_int()


end_time = time.clock()
print end_time-begin_time, "segundos"






########################################################################
# Outra forma de correr o progrma em C .... :P
########################################################################

os.system('clear')
subprocess.call(['C:\aleatorio_C.exe'])






